-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(credentials): implement form with matchExpression #481
feat(credentials): implement form with matchExpression #481
Conversation
e8e2746
to
0136296
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I'm curious if you have seen the consensus on using React.FunctionComponent here facebook/create-react-app#8177 .
It seems that the React developers say that using React.FC is unnecessary because of the issues they detail. Wanted to get your thoughts on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/test/SecurityPanel/Credentials/StoreJmxCredentials.test.tsx
Outdated
Show resolved
Hide resolved
I haven't seen that before. I don't really have any thoughts on the matter or opinion one way or the other. https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components/ I tend to like the explicit/static types where possible, but sometimes it isn't really necessary - and if the type signature is actually lying to you, like it is about the implicit If you'd like to go through and refactor to remove all those type declarations later then I wouldn't be opposed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! And all tests passed for me :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the match expression hint thing, which is up to you of course, looks great.
Good work!
There is a hint now, but it's tucked away inside of a tooltip icon so that the modal contents aren't too large and the user doesn't have to scroll too much. |
Maybe I will do a refactor in the future (the docs you linked has something for that anyways), but for now I think it may be best to stop using React.FC in
so that everything is using the same and preferred style. I'll open an issue for it, if that's okay with you anyways. This isn't a big deal by any means ^^. I'm not sure what is the best way to let everyone know though, haha. |
The best way is probably just to remove it from the codebase. New code added will naturally tend to follow the existing style found as new developers onboard and use what they read as a reference for what they write. We could also add it to a style guide document, but if it's just a written suggestion and not enforced by formatting/linting tools then it's likely to just get ignored or missed. |
@andrewazores I just have a quick question. If I enter the credential form with the exact same inputs (i.e. match expression, username, password - I guess this could be duplicate) multiple times, the credentials are appended as new. Is this intentional? |
Not exactly intentional, but harder to guard against than it seems. The username and password can definitely be duplicated across different definitions. The
are all "the same expression", but we won't catch those by simply doing We could respond with a If we could catch all of those cases then for sure, I would want to reject semantically duplicated expressions. But right now we don't have any engine for parsing and evaluating the semantics of the expression to determine logical equivalence, so I leave it as permissive and allow the user to do silly things by duplicating expressions, rather than explicitly rejecting only certain cases of identical strings. |
Ahh make sense! It is really hard to check those.
Have we considered any engine yet? |
No, and to be honest I'm not even sure such a thing exists for this use case. This is a kind of formal verification, which is an advanced topic, and JavaScript (which is what our matchExpressions really are) seems particularly hard to formally verify because of all its dynamic behaviours and types. And if it does exist, we would need it to be available as a Java package we can import as a dependency, or at least as some C library we can call out to over JNI. That's a very tight set of requirements to find anything that fits, and if it does exist I'm not sure it's even worth the effort/cost. |
Ahh got it! It sureee seems to introduce too much complication :D I think we are all good for merging? |
Oh... and I forgot about some more "easy" and "obvious" permutations too!
You can almost fake a solution by testing the new So the real solution is to parse the expressions and create something like an abstract syntax tree. You also need to analyze the tree and prune any tautological branches like Maybe you can propose this as a final year research project in a formal verification or compilers course :-) |
Yehhh that is very niceee ideaa! I have been actually thinking about this issue for a while but never gets to play around with it (too much thinking haha). I guess maybe I could do it as a side-quest every now and then too 🤣 |
Fixes #467
Test with https://github.com/cryostatio/cryostat/pull/1019 on the backend.